//
//  TabBarButton.m
//  项目一TimeMovie
//
//  Created by apple on 16/3/29.
//  Copyright © 2016年 huangmingyu. All rights reserved.
//

#import "TabBarButton.h"

@implementation TabBarButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (instancetype)initWithFrame:(CGRect)frame withImageName:(NSString *)imageName tiltleName:(NSString *)tiltle {
    
    CGFloat itemSize = 20;
    if (self = [super initWithFrame:frame]) {
        _buttonImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
        _buttonImage.frame = CGRectMake((frame.size.width - itemSize) / 2, 5, itemSize, itemSize);
        [self addSubview:_buttonImage];
        
        _buttonLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_buttonImage.frame), frame.size.width, 15)];
        
        _buttonLabel.textColor = [UIColor whiteColor];
        _buttonLabel.text = tiltle;
        _buttonLabel.textAlignment = NSTextAlignmentCenter;
        _buttonLabel.font = [UIFont boldSystemFontOfSize:14];
        
        [self addSubview:_buttonLabel];
        
    }
    return self;
}

- (void)selcetedImage:(NSString *)imageName {
    
    self.selected = YES;
    
    _buttonImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    
    
    
}

@end
